package cn.itcast.order.client.fallback;

import cn.itcast.order.client.UserClient;
import cn.itcast.order.pojo.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author xph
 * @Date 2022/8/28 18:33
 * @Description: 远程调用user-client降级工厂
 */

@Slf4j
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {

    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public User queryById(Long id) {
                log.error("查找用户失败，id:{}",id);
                return new User();
            }
        };
    }
}
